const path = require('path')

function resolve (dir) {
  return path.join(__dirname, dir)
}

console.log('环境：' + process.env.NODE_ENV)

module.exports = {
  productionSourceMap: process.env.NODE_ENV !== 'production',
  devServer: {
    inline: false,
    hot: false,
    disableHostCheck: true,
  },
  configureWebpack: {
    output: {
      filename: 'js/[name].js',
      chunkFilename: 'js/[name].[chunkhash:8].js',
    },
    externals: {
      vue: 'Vue',
      'vue-router': 'VueRouter',
      vuex: 'Vuex',
      axios: 'axios',
      'element-ui': 'ELEMENT',
      'decimal.js': 'decimal.js',
    },
  },
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('src'))
    config.plugins.delete('html')
    config.plugins.delete('preload')
    config.plugins.delete('prefetch')
  },
  filenameHashing: false,
}
